<?php
class stYoutubeToolboxHook extends sthook_2_1 {

    public function hookCustom() {        
        $method = array($this, 'showstYoutubeToolbox');
        add_shortcode('ShowstYoutubeToolbox', $method);

        $method = array($this, 'uploadRedirect');
        add_action('init', $method);
        
//        $method = array($this, 'sample');
//        add_action('init', $method);

//        $method = array($this, 'sample');
//        add_filter('init', $method);

    }
    
    public function includeExtraPlugin() {
        // default process here        
    }

    //Initialize hook function
    
    /**
     * Sample short code
     *
     * Create a short code to show stYoutubeToolbox every where
     *
     * @since Plugin expert 1.0
     */
    function showstYoutubeToolbox($args) {
        $args = shortcode_atts(array(
            'stYoutubeToolbox_id' => '0'
            ), $args);

        $controllerName = $this->config['plugin_name'] . "Controller";
        $controllerObject = new $controllerName($this->config);
        return $controllerObject->getAction('showstYoutubeToolbox', $args);
    }

    function uploadRedirect($args) {
        if($_REQUEST['status'] == 200 && !empty($_REQUEST['id'])){
            echo '<script type="text/javascript">';
            echo "window.location = '" . admin_url('/admin.php?page=' . $this->config['plugin_name'] . '&action=youtubeUploadForm&ajax=1&status=200&video_id='.$_REQUEST['id']) . "';";
            echo '</script>';
            die;
        }        
    }
}
?>